home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / text / edit / tecoc-146.lha / doeves.c < prev    next >
C/C++ Source or Header  |  1991-07-05  |  3KB  |  99 lines

  1. /*****************************************************************************
  2.     DoEvEs()
  3.  
  4.     This function "does" what's specified by the EV (edit verify) or
  5. ES (search verify) flag.  The ES and EV flags are mode control flags that
  6. allow the user to cause TECO to display a part of the edit buffer after
  7. executing a command string (edit verify) or after a search (search verify).
  8. Both the ES and EV flags are 0 by default,  which means don't do anything.
  9. This function is only called when the ES or EV flag is non-zero.
  10.     The flag is passed to this function for decoding.  This function
  11. examines the flag and acts accordingly.  Both the ES and EV flags have the
  12. following meaning:
  13.  
  14.     -1    do a 1V command to display the current line
  15.     0    do nothing (this function is not even called)
  16.     1-31    type out current line with line-feed at CP
  17.     32-255    type out current line with ASCII character (32-255) at CP
  18.     else    bottom byte as above, top byte is argument to V command
  19.  
  20. *****************************************************************************/
  21.  
  22. #if CURSES            /* need to define standout and standend? */
  23. #if ULTRIX
  24. #include <cursesX.h>        /* note: this has to come before zport.h */
  25. #else
  26. #include <curses.h>        /* note: this has to come before zport.h */
  27. #endif
  28. #endif
  29.  
  30. #include "zport.h"        /* define portability identifiers */
  31. #include "tecoc.h"        /* define general identifiers */
  32. #include "defext.h"        /* define external global variables */
  33. #include "dchars.h"        /* define identifiers for characters */
  34.  
  35. VVOID DoEvEs(Flag)        /* EV or ES flag code */
  36. WORD Flag;
  37. {
  38.     unsigned char PtChar;        /* special "CP" character */
  39.     unsigned char VLines;        /* argument to V command */
  40.  
  41.     if (Flag == 0) {
  42.     return;
  43.     }
  44.     if (Flag == -1) {            /* -1 means do a 1V command */
  45.     VLines = 1;            /* view 1 line */
  46.     PtChar = '\0';
  47.     } else {
  48.     PtChar = (unsigned char)Flag;
  49.     VLines = (unsigned char)(Flag >> 8);
  50.     if (VLines == 0) {        /* be sure it's at least 1 */
  51.         VLines = 1;
  52.     }
  53.     }
  54.  
  55.     TypBuf(GapBeg+Ln2Chr((LONG)1 - (LONG)VLines), GapBeg);
  56. #if CURSES
  57.     if (GapEnd+1 < EBfEnd) {
  58.     unsigned char c = *(GapEnd + 1);
  59.  
  60.     standout();
  61.     if (c=='\b') {
  62.         ZDspBf("^H", 2);
  63.     } else if (c=='\r') {
  64.         ZDspBf("^M", 2);
  65.     } else if (c=='\n') {
  66.         ZDspBf("^J", 2);
  67.     } else if (c & 0200) {
  68.         int i;
  69.         char a,b;
  70.  
  71.         c = c & 0177;
  72.         i = c/16;
  73.         if (i==0)
  74.         a='8';
  75.         else if (i==1)
  76.         a=9;
  77.         else
  78.         a = i - 2  + 'A';
  79.         i = (c % 16);
  80.         b = (i > 9) ?  i - 10 + 'A' : i + '0';
  81.         ZDspCh('[');
  82.         ZDspCh(a);
  83.         ZDspCh(b); 
  84.         ZDspCh(']');
  85.     } else
  86.         ZDspCh(c);
  87.     standend();
  88.     TypBuf(GapEnd+2, GapEnd + Ln2Chr((LONG)VLines)+1);
  89.     }
  90. #else
  91.     if ((PtChar >= '\001') && (PtChar <= '\037')) {
  92.     ZDspCh(LINEFD);
  93.     } else if (PtChar != 0) {
  94.     ZDspCh(PtChar);
  95.     }
  96.     TypBuf(GapEnd+1, GapEnd+Ln2Chr((LONG)VLines)+1);
  97. #endif
  98. }
  99.